<html>
<head>
	<title>ControlPlane Hacking Guide</title>
	<style type="text/css">
		table {
			border: 1px solid black;
			margin: 1em;
		}
		th {
			font-size: smaller;
		}
		th, td {
			border: 1px solid black;
			text-align: center;
		}
	</style>
</head>
<body>
<h1>ControlPlane Hacking Guide</h1>
<h2>5 August 2007</h2>

<h3>Adding a new Evidence Source</h3>
<ol>
<li>Pick a <em>short name</em> for the evidence source; no spaces, starting with a letter (e.g. <tt>Foo</tt>)</li>
<li>Create an Objective-C class called <tt>FooEvidenceSource</tt> in the same style as the other sources. It should inherit from one of these:
<table>
<tr>
	<td></td>
	<th>EvidenceSource</th>
	<th>GenericEvidenceSource</th>
	<th>LoopingEvidenceSource</th>
	<th>GenericLoopingEvidenceSource<br />(the simplest)</th>
</tr>
<tr>
	<td>Use custom nib?</td>
	<td>Yes</td>
	<td>No</td>
	<td>Yes</td>
	<td>No</td>
</tr>
<tr>
	<td>Use simple loop?</td>
	<td>No</td>
	<td>No</td>
	<td>Yes</td>
	<td>Yes</td>
</tr>
</table>
	<dl>
	<dt>If using custom nib:</dt>
		<dd><ul>
			<li>Create <em>FooRule.nib</em></li>
			<li>From your <tt>-init</tt>, call:
			<pre>
	[super initWithNibNamed:@"FooRule"];
			</pre>
			</li>
			<li>Extend:
			<pre>
	- (NSMutableDictionary *)readFromPanel;
	- (void)writeToPanel:(NSDictionary *)dict usingType:(NSString *)type
			</pre>
			</li>
		</ul></dd>
	<dt>If <b>not</b> using custom nib:</dt>
		<dd><ul><li>Override (implement):
			<pre>
	- (NSString *)getSuggestionLeadText:(NSString *)type
	- (NSArray *)getSuggestions
			</pre>
		</li></ul></dd>
	<dt>If using simple loop:</dt>
		<dd><ul><li>Extend:
			<pre>
	- (void)doUpdate
	- (void)clearCollectedData
			</pre>
		</li></ul></dd>
	<dt>If <b>not</b> using simple loop:</dt>
		<dd><ul><li>Override (implement):
			<pre>
	- (void)start
	- (void)stop
			</pre>
		</li></ul></dd>
	</dl>
</li>
<li>Add mention of it in MPController.m, around line 61:
<pre>
	[appDefaults setValue:@"YES" forKey:@"EnableFooEvidenceSource"];
</pre>
</li>
<li>Add mention of it in the three places in EvidenceSource.m, from ~ line 268:
<pre>
	#import "FooEvidenceSource.h"
	...
	[FooEvidenceSource class],
	...
	NSLocalizedString(@"Foo", @"Evidence source");
</pre>
</li>
</ol>

<h3>Adding a new Action</h3>
<ol>
<li>Pick a <em>short name</em> for the action; no spaces, starting with a letter (e.g. <tt>Foo</tt>)</li>
<li>Create an Objective-C class called <tt>FooAction</tt> in the same style as the other actions</li>
<li>Add mention of it in the three places in Action.m (from around line 146):
<pre>
	#import "FooAction.h"
	...
	[FooAction class],
	...
	NSLocalizedString(@"Foo", @"Action type")
</pre>
</li>
</ol>

</body>
</html>
